#!/usr/bin/env python
# coding: utf-8

import logging

def abstract_method():
    import inspect
    caller = inspect.getouterframes(inspect.currentframe())[1][3]
    raise NotImplementedError(caller + ' must be implemented in subclass')

class xxx_element(object):
    def __init__(self):
        logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s %(levelname)-8s %(name)-16s : %(message)s',
                        # filemode='w')
                        )
        self.logger = logging.getLogger(self.__class__.__name__)
        
    def __del__(self):
        self.disconnect()
        
    def connect(self, ip, slot, port, usr=None, pwd=None):
        abstract_method()
        
    def disconnect(self, ip=None, slot=None, port=None):
        abstract_method()

    def send(self, cmd, rtn_flag='', ip=None, slot=None, port=None):
        abstract_method()
        
    def send_only(self, cmd, ip=None, slot=None, port=None):
        abstract_method()
        
    def send_rtn_str(self, cmd, ip=None, slot=None, port=None):
        abstract_method()
        
def test():
    net = xxx_element()
    print (net)
    print (net.logger)
    print (net.__class__.__name__)
    print (net.connect())
    
if __name__ == "__main__":
    test()